package com.itheima.web;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
//@PreAuthorize("hasRole('bbb')")
public class TestController {

    @Resource
    private RedisTemplate<String,Object> redisTemplate;

    @GetMapping("/test")
    //bbb访问
//    @PreAuthorize("hasRole('bbb')")
    public String test(){
        //set get
        redisTemplate.opsForValue().set("name","hello world");
        return "ok";
    }

    @GetMapping("/sayHello/{name}")
    //aaa访问
    public String sayHello(@PathVariable("name") String name){
        //69b9f231-f6fc-409b-b017-250ad73d7d15
        //0884d394-71d4-4f26-9a75-9d508f3cff4e
        return "hello:" + name;
    }

}
